package borders;

import squares.Square;

/**
 * a door class that is a special case of border. it contains an extra variable,
 * namely to specify if the door is open or closed.
 * @Invar each Border can have his first attached square as an attached square. (inherited from the class parent)
 * 			| Border.isValidAttachedSquare(Border.getAttachedSquare1())
 * @Invar each Border can have his second attached square as an attached square. (inherited from the class parent)
 * 			| Border.isValidAttachedSquare(Border.getAttachedSquare2())
 * @version 1.0
 * @author Gilles Groven & Jochen Tombal
 */
public class Door extends Border {
	
	private boolean open;
	/**
	 * Initializes this door with the given square as attached square and the given value for the state of the door.
	 * @param square1
	 * 		the attached square for this door.
	 * @param isOpen
	 * 		the state of the door (open or closed)
	 * @effect the door is initialized as a new border with the given square as attached square
	 * 		|super(square1)
	 * @post the given state of the door is the new state of the door.
	 * 		| new.getIsOpen() == isOpen
	 */
	public Door(Square square1,boolean isOpen)
	{
		super(square1);
		setIsOpen(isOpen);
		
	}
	/**
	 * Initializes this door with the given squares as attached squares and the given value for the state of the door.
	 * @param square1
	 * 		the first attached square for this door.
	 * @param square2
	 * 		the second attached square for this door.
	 * @param isOpen
	 * 		the state of the door (open or closed)
	 * @effect the door is initialized as a new border with the given squares as attached squares
	 * 		|super(square1,square2)
	 * @post the given state of the door is the new state of the door.
	 * 		| new.getIsOpen() == isOpen;
	 */
	public Door(Square square1,Square square2,boolean isOpen)
	{
		super(square1,square2);
		setIsOpen(isOpen);
	}
	/**
	 * Initializes this door with no attached squares and a closed door.
	 * @effect the door is initialized with no borders.
	 * 		|super()
	 * @post the state of the door is closed.
	 * 		| new.getIsOpen() == false;
	 */
	public Door()
	{
		
	}
	/**
	 * opens or closes the door, depending of the given value.
	 * @param isOpen
	 * 		sets the door the door to open or closed, depending of the value.
	 * @post the state of the door is equal to the given boolean
	 * 		| getIsOpen() == isOpen;
	 */
	public void setIsOpen(boolean isOpen)
	{
		this.open = isOpen;
	}
	/**
	 * @return the state of the door.
	 */
	public boolean getIsOpen()
	{
		return this.open;
	}
	
	
}
